/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cheetah.sisal.obj;

/**
 *
 * @author edoardo
 */
public class MergedCell {

    private int colNumber;
    private int rowNumber;

    private int firstRow;
    private int lastRow;

    public MergedCell(int colNumber, int rowNumber) {
        this.colNumber = colNumber;
        this.rowNumber = rowNumber;
    }

    private int firstColumn;
    private int lastColumn;

    public int getColNumber() {
        return colNumber;
    }

    public void setColNumber(int colNumber) {
        this.colNumber = colNumber;
    }

    public int getRowNumber() {
        return rowNumber;
    }

    public void setRowNumber(int rowNumber) {
        this.rowNumber = rowNumber;
    }

    public int getFirstRow() {
        return firstRow;
    }

    public void setFirstRow(int firstRow) {
        this.firstRow = firstRow;
    }

    public int getLastRow() {
        return lastRow;
    }

    public void setLastRow(int lastRow) {
        this.lastRow = lastRow;
    }

    public int getFirstColumn() {
        return firstColumn;
    }

    public void setFirstColumn(int firstColumn) {
        this.firstColumn = firstColumn;
    }

    public int getLastColumn() {
        return lastColumn;
    }

    public void setLastColumn(int lastColumn) {
        this.lastColumn = lastColumn;
    }

    @Override
    public String toString() {
        return getKey();
    }

    @Override
    public int hashCode() {
        return getKey().hashCode();
    }

   
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final MergedCell other = (MergedCell) obj;
        return getKey().equals(other.getKey());
    }

    
    
    public String getKey(){
        String row = getLastRow()-getFirstRow()==0?new StringBuilder("(").append(getFirstRow()).append(")").toString():
                new StringBuilder("(").append(getFirstRow()).append(",").append(getLastRow()).append(")").toString();
        String column = getLastColumn()-getFirstColumn()==0?new StringBuilder("(").append(getFirstColumn()).append(")").toString():
                new StringBuilder("(").append(getFirstColumn()).append(",").append(getLastColumn()).append(")").toString();
        return new StringBuilder(row).append(column).toString();
    }
    
}
